import React from 'react'

import { getMovieAction } from '../../store/movieSlice'

import { useDispatch, useSelector } from 'react-redux'

export default function Movie() {
  const dispatch = useDispatch()
  const count = useSelector(state => state.count.count)
  const movie = useSelector(state => state.movie.movieList)
  // const {movie}=store.getState().movie
  const getMovieHandle = async () => {

    dispatch(getMovieAction())
  }


  return (
    <div>
      <div>count的值我也有{count}</div>
      <button onClick={getMovieHandle}>点击查询电影</button>
      <h1>电影的个数为{movie.length}</h1>
      <ul>
        {movie.map(item => {
          return <li key={item.albumId}>{item.name}</li>
        })}
      </ul>
    </div>
  )
}
